package com.yc.system.controller;

import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yc.system.entity.Book;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;

import  com.yc.system.service.IStoreService;


import com.yc.framework.baseClass.BaseController;
//import com.yc.framework.baseClass.ServiceFacade;
import com.yc.framework.baseClass.R;
import com.yc.system.entity.Store;
/**
 * <p>
    * 书店 前端控制器
    * </p>
 *
 * @author 1850140986@qq.com
 * @since 2022-12-06
 */
@RestController
//@RequestMapping("/sys/store")
public class StoreController extends BaseController
    {

    @Autowired
        //private IStoreService t_storeService;
  private IStoreService service;

  /**
   * 根据条件分页查询Store
   * @param model 实体对象
   * @return 查询列表
   */
     @PostMapping("/sys/store/list")
    public R list(@RequestBody Store model){
        return service.list(model);

    }

    /**
    * 根据主键查询单个对象
    * @param model 实体对象包含uuid
    * @return 成功或失败
    */
    @GetMapping("/sys/store/getById/{id}")
    public R getById(@PathVariable String id) {
        return service.getModelById(id);
    }

    /**
	 * 新增实体对象
	 *
     * @param model 实体对象
	 * @return 新增是否成功
	 */
     @PostMapping("/sys/store/save")
	public R save(@RequestBody Store model) {
		return service.saveModel(model);

	}

    /**
	 * 批量新增实体对象
	 *
     * @param modelList 实体对象列表
	 * @return 新增是否成功
	 */
	@PostMapping("/sys/store/saveBatch")
	public R saveBatch(@RequestBody List<Store> modelList) {
		return service.saveModelBatch(modelList);

	}

    /**
	 * 根据主键删除实体
	 *
     * @param uuid 实体携带主键
	 * @return 删除是否成功
	 */
	@DeleteMapping("/sys/store/removeById/{id}")
	public R removeById(@PathVariable String id) {
		return service.removeModelById(id);
	}

     /**
	 * 根据主键列表删除实体
	 *
     * @param idList 实体主键
	 * @return 删除是否成功

	@DeleteMapping("/removeByIdList")
	public R removeByIdList(@RequestBody List<Store> idList) {
        return service.removeModelByIdList(idList);

    }
 */
    /**
    * 根据主键修改实体
    *
    * @param model 等待修改的对象
    * @return 修改是否成功
    */
    @PutMapping("/sys/store/updateById")
    public R updateModelById(@RequestBody Store model) {
        return service.updateModelById(model);

    }

    /**
    * 根据主键列表修改实体列表
    *
    * @param modelList 等待修改的对象列表
    * @return 修改是否成功
    */
    @PostMapping("/sys/store/updateByIdBatch")
    public R updateModelByIdBatch(@RequestBody List<Store> modelList) {
        return service.updateModelByIdBatch(modelList);

    }

      /**
	 * 根据多主键列表删除实体
	 *
     * @param idList 多主键
	 * @return 删除是否成功
	 */
	@DeleteMapping("/sys/store/removeByIds/{ids}")
	public R removeByIdList(@PathVariable String ids) {
        return service.removeModelByIds(ids);

    }

		@PostMapping("/sys/store/getStoresByPage")
		public R getStoresByPage(@RequestBody Store findByPage){
			return service.getStoresByPageRandom(findByPage);
		}

		@GetMapping("/sys/store/getIssureInfoByUserId")
		public R getIssureInfoByUserId(@RequestParam("userId") int userId){
			return service.getIssureInfoByUserId(userId);
		}

		@PostMapping("/index/sys/store/getStoresAllByPage")
		public R getStoresAllByPage(@RequestBody Store findByPage){
			return service.getStoresAllByPage(findByPage);
		}

		@GetMapping("/sys/store/getStoreByUserId")
		public R getStoreByUserId(@RequestParam("userId") int userId){
		return  R.ok().put("data",service.getStoreByUserId(userId));
		}

		@PostMapping("/sys/store/toStore")
		public R toStore(@RequestBody Store store){
			return  service.saveModel(store);
		}

}
